import request from '@/utils/request'

/**
 * 删除部门接口方法
 * @param {number} id
 */
export const deleteDepartmentAPI = (id) => {
  return request.delete(`/company/department/${id}`)
}

/**
 * 修改部门接口方法：put请求告诉服务端修改谁(id)，把他改成什么样(data)
 * @param {object} data 修改后的部门表单数据对象
 */
export const updateDepartmentAPI = (data) => {
  return request.put(`/company/department/${data.id}`, data)
}

/**
 * 获取部门详情数据接口方法
 * @param {number} id 部门ID
 */
export const getDepartmentDetailAPI = (id) => {
  // return request.get(`/company/department${id}`) // 错误写法: 少了斜杠
  return request.get(`/company/department/${id}`) // 正确写法
}

/**
 * 添加子部门接口方法
 * @param {object} data 部门表单数据对象
 */
export const addDepartmentAPI = (data) => {
  return request.post('/company/department', data)
}

/**
 * 获取部门负责人列表接口方法
 */
export const getManagersAPI = () => {
  return request.get('/sys/user/simple')
}

/**
 * 获取部门列表数据接口方法
 */
export const getDepartmentsAPI = () => {
  return request.get('/company/department')
}
